﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework;
using Arcadium.Graphics;
using Arcadium.Screens.Menus.MenuHelpers;
using Arcadium.Audio;

namespace Arcadium
{
    class StartupScreen : GameScreen
    {
        #region Field

        private Texture2D voluminousInteractiveLogo;

        #endregion

        #region Initialization


        /// <summary>
        /// Constructor.
        /// </summary>
        public StartupScreen()
        {
            TransitionOnTime = TimeSpan.FromSeconds(3);
            TransitionOffTime = TimeSpan.FromSeconds(1);
        }

        public override void LoadContent()
        {
            ContentManager content = ScreenManager.Game.Content;
            voluminousInteractiveLogo = content.Load<Texture2D>("Extras\\VoluminousInteractive");
            base.LoadContent();
        }

        #endregion

        #region Update and Draw


        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
                                                       bool coveredByOtherScreen)
        {
            base.Update(gameTime, otherScreenHasFocus, false);

            if (this.ScreenState == ScreenState.Active)
            {
                // Let this screen transition off and show the activation screen
                LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(),
                    new ActivationScreen());

                AudioManager.Create(ScreenManager.Game);

                AudioManager.PlaySong(5);

            }
        }

        /// <summary>
        /// Draws the startup screen.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch spriteBatch = ViewResource.SpriteBatch;

            spriteBatch.Begin();
            
            spriteBatch.Draw(voluminousInteractiveLogo, View.Adjust(new Vector2(View.ScreenWidth, View.ScreenHeight) / 2), null,
                Color.White * this.TransitionAlpha, 0, new Vector2(voluminousInteractiveLogo.Width, 
                    voluminousInteractiveLogo.Height) / 2, 
                1, SpriteEffects.None, 0);

            spriteBatch.End();
        }


        #endregion

    }
}
